#include<stdio.h>
#include<bits/stdc++.h> 
using namespace std;
long long n,l,r;
inline long long read()
{
	char c=getchar();
	int f=1;
	long long sum=0;
	while(c!='-'&&(c<'0'||c>'9'))c=getchar();
	if(c=='-')
	{
		f=-1; 
		c=getchar();
	} 
	do
	{
		sum=(sum<<3)+(sum<<1)+c-'0'; 
		c=getchar();
	}while(c>='0'&&c<='9');
	return sum*f;
}
int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	n=read(),l=read(),r=read();
	long long mn=l/n,mx=(l+n-1)/n;
	mn*=n,mx*=n;
	long long ans=r-mn,ans2=r-mx;
	//printf("%d %d %d\n",mn,ans,r); 
	if(ans>=n||ans2>=n)
	{
		printf("%d",n-1);
	}
	else
	{
		printf("%d",max(ans,max(0*1ll,ans2)));
	}
}
